package com.edu.d7_tcp4;

import java.io.*;
import java.net.Socket;

/**
 * BS架构
 */
public class ServerReaderThread extends Thread{
    private Socket socket;
    public ServerReaderThread(Socket socket) {
        this.socket=socket;
    }

    @Override
    public void run() {

        /**
         * 立即响应一个网页内容，给浏览器显示
         */
        try {
            OutputStream outputStream = socket.getOutputStream();

            PrintStream printStream = new PrintStream(outputStream);
            printStream.println("HTTP/1.1 200 OK");
            printStream.println("Content-Type:text/html;charset=UTF-8");
            printStream.println();//必须换行
            printStream.println("<div style='color:red;font-size:120px;text-align:center'>黑阿黑啊黑啊黑啊<div>");
            printStream.close();
            socket.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
}
